# -*- coding:utf-8 -*-
"""
Created on 2010-2-8

@author: summit
"""

import wx
import wx.aui

from jolly.wxext.wxFWSVTKPageView import *

from jolly.visual.vtkPythonViewImageCollection import *
from jolly.visual.vtkPythonViewImage2D import *
from jolly.visual.vtkPythonViewImage3D import *
from jolly.datamanagement.vtkPythonDataManager import *

from jolly.wxext.wxVTKPageView import *

class Yuki(wx.Frame):
    '''
    New yuki for 2010 Spring Festival
    '''
    # The view in Yuki's client
    __viewxy=None
    __viewyz=None
    __viewxz=None
    __view3D=None
    __vtkpageview=None
    
    def __init__(self, parent, id=wx.ID_ANY, title="Yuki log(100!)", pos= wx.DefaultPosition,
                 size=(800, 600), style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER|wx.MAXIMIZE):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        self.__vtkpageview = wxFWSVTKPageView(self)
        self.__viewcollection = vtkPythonViewImageCollection()
        self.__view3D = vtkPythonViewImage3D()
        self.__viewcollection.AddItem(self.__view3D)
        self.__datamanager = vtkPythonDataManager()
        
        self.__viewxy = vtkPythonViewImage2D()
        self.__viewxy.SetInput(None)
        self.__viewxy.GlobalWarningDisplayOff()
        
        # vtkPythonViewImage just provide some advance feature to control the 
        # view, but create interactor and render window is not its responsibility
        # so, next two sentence associate the wxVTKPageView's view to vtkPythonViewImage
        self.__viewxy.SetupInteractor(self.__vtkpageview.viewInteractor1)
        self.__viewxy.SetRenderWindow(self.__vtkpageview.viewInteractor1.GetRenderWindow())
        self.__viewxy.SetInteractorStyleTypeToNavigation()
        self.__viewxy.SetSliceOrientationToXY()
        self.__view3D.Add2DPhantom(self.__viewxy.GetImageActor())
        self.__viewcollection.AddItem(self.__viewxy)
        
        self.__viewyz = vtkPythonViewImage2D()
        self.__viewyz.SetInput(None)
        self.__viewyz.GlobalWarningDisplayOff()
        self.__viewyz.SetupInteractor(self.__vtkpageview.viewInteractor2)
        self.__viewyz.SetRenderWindow(self.__vtkpageview.viewInteractor2.GetRenderWindow())
        self.__viewyz.SetInteractorStyleTypeToNavigation()
        self.__viewyz.SetSliceOrientationToYZ()
        self.__viewcollection.AddItem(self.__viewyz)
        self.__view3D.Add2DPhantom(self.__viewyz.GetImageActor())
        
        self.__viewxz = vtkPythonViewImage2D()
        self.__viewxz.SetInput(None)
        self.__viewxz.GlobalWarningDisplayOff()
        self.__viewxz.SetupInteractor(self.__vtkpageview.viewInteractor3)
        self.__viewxz.SetRenderWindow(self.__vtkpageview.viewInteractor3.GetRenderWindow())
        self.__viewxz.SetInteractorStyleTypeToNavigation()
        self.__viewxz.SetSliceOrientationToXZ()
        self.__viewcollection.AddItem(self.__viewxz)
        self.__view3D.Add2DPhantom(self.__viewxz.GetImageActor())
        
        self.__view3D.SetInput(None)
        self.__view3D.GlobalWarningDisplayOff()
        self.__view3D.SetupInteractor(self.__vtkpageview.viewInteractor4)
        self.__view3D.SetRenderWindow(self.__vtkpageview.viewInteractor4.GetRenderWindow())
        self.__view3D.SetRenderingModeToPlanar()
        self.__view3D.InstallPipeline()
        
        self.__mgr = wx.aui.AuiManager()
        self.__mgr.SetFlags(wx.aui.AUI_MGR_RECTANGLE_HINT or wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE )
        self.__mgr.SetManagedWindow(self)
        self.DoLayout()
    
    def DoLayout(self):
        self.__mgr.AddPane(self.__vtkpageview, wx.aui.AuiPaneInfo().Name("PageView").Caption("PageView").CenterPane().PaneBorder(False))
        self.__mgr.Update()
        

if __name__=="__main__":
    app = wx.PySimpleApp()
    frame = Yuki(None)
    frame.Show(True)
    app.MainLoop()